<template>
	<view class="login-settings-page">
		<!-- 顶部导航 -->
		<!-- <view class="header-bag">
			<view class="back" @click="goBack">
				<image src="/static/img/icon-Get-into@3.png" class="back-icon" mode="aspectFit" />
			</view>
			<view class="header-center">
				<text class="header-title">登录设置</text>
			</view>
			<view class="header-right"></view>
		</view> -->
		
		<!-- 设置列表 -->
		<view class="wrapper">
			<view class="set-nav">
				<view class="nav-item" @click="goChangePhone">
					<view class="item-left">
						<text class="item-title">更换手机号</text>
					</view>
					<view class="item-right">
						<image :src="serverAddress+'img/icon-back1.png'" class="arrow-icon" mode="aspectFit" />
					</view>
				</view>
				
				<view class="nav-item" @click="goChangePassword">
					<view class="item-left">
						<text class="item-title">修改登录密码</text>
					</view>
					<view class="item-right">
						<image :src="serverAddress+'img/icon-back1.png'" class="arrow-icon" mode="aspectFit" />
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { userApi } from '@/api/index.js'
import {
		inject
	} from 'vue'
export default {
	data() {
		return {
			serverAddress: inject('$serverAddress'),
			userInfo: {}
		}
	},
	onLoad() {
		this.checkUserPhone()
	},
	methods: {
		// 返回上一页
		goBack() {
			uni.navigateBack()
		},
		
		// 检查用户手机号
		checkUserPhone() {
			try {
				const userInfo = uni.getStorageSync('user_info')
				if (!userInfo || !userInfo.phone) {
					// 如果没有手机号，跳转到绑定手机号页面
					uni.redirectTo({
						url: '/pages/login/phone-bind'
					})
					return
				}
				this.userInfo = userInfo
			} catch (error) {
				console.error('获取用户信息失败:', error)
				uni.showToast({
					title: '获取用户信息失败',
					icon: 'none'
				})
			}
		},
		
		// 跳转到更换手机号页面
		goChangePhone() {
			uni.navigateTo({
				url: '/pages/my/set-loginphone'
			})
		},
		
		// 跳转到修改密码页面
		goChangePassword() {
			uni.navigateTo({
				url: '/pages/my/change-password'
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.login-settings-page {
	background-color: #f7f7f7;
	height: 100vh;
	display: flex;
	flex-direction: column;
}

// 顶部导航
.header-bag {
	height: 88rpx;
	background-color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 30rpx;
	border-bottom: 1rpx solid #f0f0f0;
	position: relative;
	
	.back {
		padding: 10rpx;
		
		.back-icon {
			width: 24rpx;
			height: 48rpx;
		}
	}
	
	.header-center {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: center;
		
		.header-title {
			font-size: 32rpx;
			font-weight: 500;
			color: #333;
		}
	}
	
	.header-right {
		width: 44rpx; // 占位元素，保持标题居中
	}
}

// 内容区域
.wrapper {
	background-color: white;
	font-size: 56rpx;
	flex: 1;
	padding-top: 20rpx;
}

// 设置导航列表
.set-nav {
	padding: 0 30rpx;
	background-color: white;
	
	.nav-item {
		padding: 20rpx 0;
		border-bottom: 1rpx solid #E8E8E8;
		display: flex;
		align-items: center;
		justify-content: space-between;
		
		&:last-child {
			border-bottom: none;
		}
		
		&:active {
			background-color: #f5f5f5;
		}
		
		.item-left {
			flex: 1;
			
			.item-title {
				font-size: 32rpx;
				color: #333333;
			}
		}
		
		.item-right {
			display: flex;
			align-items: center;
			
			.arrow-icon {
				width: 28rpx;
				height: 25rpx;
			}
		}
	}
}
</style>